<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        .active {
            border: 1px solid red;
            width: 100px;
            height: 100px;
        }
        
        .error {
            background-color: orange;
        }
        
        .test {
            color: blue;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- 动态添加类 -->
        <div v-bind:class="[activeClass,errorClass,{test:isText}]">测试样式</div>
        <div v-bind:class="arrClasses"></div>
        <button v-on:click="handle">切换</button>
    </div>
    <!-- 样式绑定相关语法细节
         1、对象绑定和数组绑定可以结合使用
         2、class绑定的值可以简化操作
         3、默认的class如何处理？ 默认的class绑定事件中会保留
    -->
    <script src="./vue.js "></script>
    <script>
        var vm = new Vue({
            el: "#app ",
            data: {
                activeClass: "active",
                errorClass: "error",
                isText: true,
                arrClasses: ["active", "error"],
            },
            methods: {
                handle: function() {
                    this.isText = false;
                },
            },
        });
    </script>
</body>

</html>